package net.m2m.policyeditor.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class CopyOfCreatePolicyForm {
	private Text tPolicyName;
	private Text tDefinedBy;
		
	private Text tEventName;	
	private Text tM2MService;
	private Text tM2MDevice;
	
	private Text tConditionArgument1Name;
	private Text tConditionArgument1Value;
	private Text tConditionArgument1GreaterThan;
	private Text tConditionArgument1LessThan;
	
	private Text tConditionArgument2Name;
	private Text tConditionArgument2Value;
	private Text tConditionArgument2GreaterThan;
	private Text tConditionArgument2LessThan;
	
	private Text tConditionArgument3Name;
	private Text tConditionArgument3Value;
	private Text tConditionArgument3GreaterThan;
	private Text tConditionArgument3LessThan;
	
	private Text tActionArgument1Name;
	private Text tActionArgument1Value;
	
	private Text tActionArgument2Name;
	private Text tActionArgument2Value;
	
	private Text tActionArgument3Name;
	private Text tActionArgument3Value;
		
	private Button btCreate;
	private Button btCancel;	
	
	public void ButtonEvent(SelectionListener selListenner) {
		btCreate.addSelectionListener(selListenner);		
	}
	
	public void CreatePolicyForm(Shell shell) {
		
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 5;
		gridLayout.makeColumnsEqualWidth = true;
		
		gridLayout.horizontalSpacing = 15;
		gridLayout.verticalSpacing = 10;
		
		gridLayout.marginWidth = 15;
		gridLayout.marginHeight = 15;
	
		GridData gridData = new GridData();
		gridData.heightHint = 20;
		gridData.widthHint = 110;	
		gridData.horizontalSpan = 2;
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.BEGINNING;
					
		Group gPolicyEditor = new Group(shell, SWT.NULL);
		gPolicyEditor.setLayout(gridLayout);
		gPolicyEditor.setText("Create Policy");
		
		GridData lbData = new GridData();
		lbData.widthHint = 100;
		lbData.horizontalAlignment = GridData.CENTER;
		lbData.horizontalIndent = 30;
		lbData.grabExcessHorizontalSpace = true;
				
		Label label = new Label(gPolicyEditor, SWT.NONE);				
		label.setText("Policy");		
		GridData nGridData1 = new GridData();
		nGridData1.horizontalSpan = 4;
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Policy Name");
		label.setLayoutData(lbData);
		tPolicyName = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tPolicyName.setLayoutData(gridData);		
		nGridData1.horizontalSpan = 8;
		nGridData1.heightHint = 1;
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Defined By");
		label.setLayoutData(lbData);
		tDefinedBy = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tDefinedBy.setLayoutData(gridData);				
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);				
		label.setText("Event");		
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Event Name");
		label.setLayoutData(lbData);
		tEventName = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tEventName.setLayoutData(gridData);		
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("M2M Service");
		label.setLayoutData(lbData);
		tM2MService = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tM2MService.setLayoutData(gridData);		
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		////////////////////////////////////////////////////////////////////////////////////////////////

		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("M2M Device");
		label.setLayoutData(lbData);
		tM2MDevice = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tM2MDevice.setLayoutData(gridData);		
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);		
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Condition");		
		nGridData1 = new GridData();
		nGridData1.horizontalSpan = 4;
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);
		new Label(gPolicyEditor, SWT.NONE);
			
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Name");	
		label.setLayoutData(lbData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Value");
		label.setLayoutData(lbData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Greater than");
		label.setLayoutData(lbData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Less than");
		label.setLayoutData(lbData);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		gridData = new GridData();
		gridData.heightHint = 20;
		gridData.widthHint = 110;	
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.BEGINNING;
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 1");
		label.setLayoutData(lbData);
		tConditionArgument1Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument1Name.setLayoutData(gridData);
		tConditionArgument1Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument1Value.setLayoutData(gridData);
		tConditionArgument1GreaterThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument1GreaterThan.setLayoutData(gridData);
		tConditionArgument1LessThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument1LessThan.setLayoutData(gridData);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 2");
		label.setLayoutData(lbData);
		tConditionArgument2Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument2Name.setLayoutData(gridData);
		tConditionArgument2Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument2Value.setLayoutData(gridData);
		tConditionArgument2GreaterThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument2GreaterThan.setLayoutData(gridData);
		tConditionArgument2LessThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument2LessThan.setLayoutData(gridData);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 3");
		label.setLayoutData(lbData);
		tConditionArgument3Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument3Name.setLayoutData(gridData);
		tConditionArgument3Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument3Value.setLayoutData(gridData);
		tConditionArgument3GreaterThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument3GreaterThan.setLayoutData(gridData);
		tConditionArgument3LessThan = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tConditionArgument3LessThan.setLayoutData(gridData);
		
		nGridData1 = new GridData();
		nGridData1.horizontalSpan = 5;
		nGridData1.heightHint = 1;
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Action");		
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);
		new Label(gPolicyEditor, SWT.NONE);		
		
		
		GridData lbData2 = new GridData();
		lbData2.widthHint = 100;
		lbData2.horizontalAlignment = GridData.CENTER;
		lbData2.horizontalIndent = 30;
		lbData2.grabExcessHorizontalSpace = true;
		lbData2.horizontalSpan = 2;
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Name");	
		label.setLayoutData(lbData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Value");
		label.setLayoutData(lbData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		gridData = new GridData();
		gridData.heightHint = 20;
		gridData.widthHint = 110;	
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.BEGINNING;
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 1");
		label.setLayoutData(lbData);
		tActionArgument1Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument1Name.setLayoutData(gridData);
		tActionArgument1Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument1Value.setLayoutData(gridData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 2");
		label.setLayoutData(lbData);
		tActionArgument2Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument2Name.setLayoutData(gridData);
		tActionArgument2Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument2Value.setLayoutData(gridData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setText("Argument 3");
		label.setLayoutData(lbData);
		tActionArgument3Name = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument3Name.setLayoutData(gridData);
		tActionArgument3Value = new Text(gPolicyEditor, SWT.SINGLE | SWT.BORDER);
		tActionArgument3Value.setLayoutData(gridData);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		label = new Label(gPolicyEditor, SWT.NONE);
		label.setLayoutData(lbData2);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
			
		nGridData1 = new GridData();		
		nGridData1.horizontalSpan = 2;
		new Label(gPolicyEditor, SWT.NONE).setLayoutData(nGridData1);
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		Composite btCompsite = new Composite(gPolicyEditor, SWT.NONE);
		RowLayout rLayout = new RowLayout();
		rLayout.spacing = 15;
		btCompsite.setLayout(rLayout);
		btCreate = new Button(btCompsite, SWT.PUSH);
		btCreate.setText("Create");
		btCancel = new Button(btCompsite, SWT.PUSH);
		btCancel.setText("Cancel");		
		btCompsite.pack();		
	}
}
